﻿using System;
using NHibernate.Event;
using FluentNHibernate.Cfg;
using Caramel.NHibernate.Entities;

namespace Caramel.FluentNHibernate
{
	public static class FluentConfigurationExtensions
	{
		public static FluentConfiguration ConfigureListeners(this FluentConfiguration cfg)
		{
			return
				cfg.
					ExposeConfiguration(
						config =>
						{
							config.EventListeners.PreInsertEventListeners = new IPreInsertEventListener[] { new PreInsertEntityEventListener() };
							config.EventListeners.PreUpdateEventListeners = new IPreUpdateEventListener[] { new PreUpdateEntityEventListener() };
						}
					);
		}
	}
}
